import Vue from 'vue'
import Vuex from 'vuex'
import actions from './action'
import mutations from './mutations.js'
import getters from './getters'
import state from './state'
// 永久存储数据
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const store = new Vuex.Store({
  // 永久储存配置
  plugins: [createPersistedState({
    storage: window.sessionStorage,
    reducer (val) {
      return {
        // 只储存state中的某一项
        userInfo: val.userInfo
      }
    }
  })],
  actions,
  mutations,
  getters,
  state
})

export default store
